module.exports = function ($scope, $state, $resource, $modal, toaster) {
	$scope.myKeyup = function (e) {
		//IE 编码包含在window.event.keyCode中，Firefox或Safari 包含在event.which中
		var keycode = window.event ? e.keyCode : e.which;
		if (keycode == 13) {
			$scope.loadlist();
		}
	};
		/* 分页
   * ========================================= */
  $scope.maxSize = 5;            //最多显示多少个按钮
  $scope.bigCurrentPage = 1;      //当前页码
  $scope.itemsPerPage = 10; 
  $scope.searchform = {};
	//卡列表
	$scope.loadlist = function () {
    var para = {
        pageNo:$scope.bigCurrentPage, 
        pageSize:$scope.itemsPerPage
    };
    para = angular.extend($scope.searchform, para);
		$resource('/api/as/mc/apply/findCompanyList', {}, {}).save(para, function (res) {
			if (res.errcode === 0) {
        $scope.objs = res.data.results;
        $scope.bigTotalItems = res.data.totalRecord;
			} else {
				toaster.error({ title: '', body: res.errmsg });
			}
		});
	}

	$scope.loadlist();

	
  $scope.agree = function (obj){
      var modalInstance = $modal.open({
          template: require('../views/examinePass.html'),
          controller: 'examinePass',
          size: 'lg',
          resolve: {
              item : function () {
                  return obj;
              }
          }
      });
      //关闭模态框刷新页面
      modalInstance.result.then(function() {
        $scope.loadlist();
      });
  }
  $scope.disagree = function (obj){
      if (confirm('确定拒绝该申请吗?')){
          $resource('/api/as/mc/usertaopiaorole/updateTaopiaoApplyNo', {}, {}).save({'id' : obj.id}, function (res) {
            if (res.errcode === 0) {
              toaster.error({ title: '', body: '拒绝成功' });
              $scope.loadlist();
            } else {
              toaster.error({ title: '', body: res.errmsg });
            }
          });
      }
  }
  

};